No filename provided!\n" . "

You need to pass " . "file=name in the query string.\n" . "You can also add the linenums parameter " . "to display line numbers, the nodir " . "parameter to truncate the heading to only show the filename, " . "and the dl parameter to add a download link " . "(useful when showing line numbers).

\n"; echo '
'; exit; } if ( ! isset($dl) or $dl == "false" ) $dl = false; else $dl = true; if ( ! isset($linenums) or $linenums == "false" ) $linenums = false; else $linenums = true; // "nodir" means to only display the filename in the heading, // and not the pathname. if ( ! isset($nodir) or $nodir == "false" ) $nodir = false; else $nodir = true; // Output HTML document body (the file's contents): if ( $nodir ) echo "

" . basename($file) . "

\n"; else echo "

$file

\n"; if ( $dl ) echo "

Download " . basename($file) . "

\n"; echo "
\n";

//   echo htmlentities( file_get_contents($file) );
   $contents = file( $file, FILE_IGNORE_NEW_LINES );
   $linenumwidth = strlen( count($contents) );
   $format = "%" . $linenumwidth . "d: ";
   
   foreach ($contents as $line_num => $line) {
      if ( $linenums )
         printf( $format, ($line_num + 1) );
      echo htmlentities( rtrim($line) ) . "\n";
   }

   // Output HTML epilog:
   echo "
\n"; ?>
// ' ?>